
var onReady = function(acc){
	alert("onReady("+ acc.data.version +")");
};

var onDestroy = function(acc){
	alert("onDestroy("+ acc.data.version +")");
};


$(document).ready(function(){
	var props = new Object();
		props.wrapperClassName 	= "rs_accordion_wrapper";
		props.barClassName 		= "rs_accordion_bar";
		props.contentClassName 	= "rs_accordion_content";
		props.callback = onReady;
		//
	var accordion = $("#example").RSAccordion(props); 
		accordion.bind("onReady", accordion, onReady);
		accordion.bind("onDestroy", accordion, onDestroy);
	var secondItem = accordion.getItemByIndex(1);
	var tiltle = $(secondItem).find("a").html();
	// alert("The title of the second tab is: " + tiltle);
	top.addItem = function (){
		accordion.addItem('<div><div class="rs_accordion_bar">Item '+ Math.ceil(Math.random()*1000)  +' </div><div class="openAction option">toggle</div></div>', '<div class="rs_accordion_content">New item ' + new Date()+'</div>');
	};
	
	top.drawItems = function (){
		var ulString = ''+
	  	'<ul id="example"">';
	  	var limit = Math.ceil(Math.random()*10);
	  	for(var i=0; i<limit; i++){
			ulString += '<li>'+
				'<div><div class="rs_accordion_bar">Test ['+ i +'] '+Math.ceil(Math.random()*1000)+' </div><div class="openAction option">toggle</div></div>'+
				'<div class="rs_accordion_content">'+ i +' content</div>'+
			'</li>';
	  	}
		ulString += '</ul>';
		accordion.draw(ulString);
	}
});

